<?php
require_once("../../../config.inc.php");
require_once("../../../app/_inc/include.php");

$errMsg = sxREQ('msg');

$objUser = $_SESSION[USEROBJ];
if(sxREQ('mod')==''){
	$url = $_SESSION[USEROBJ]->getHistory(-1, true).
		"&msg=".urlencode(_t("variabile 'mod' non passata")); 
	serverRedir($url);
}
$module = sxREQ('mod');
$sSQL = "SELECT fa.*, m.description AS mdes FROM  module m " .
		" LEFT JOIN functional_area fa ON fa.module = m.module " .
		" WHERE m.module = '".sxRAS('mod')."' " .
		" ORDER BY fa.functional_area ";
$query = $objSDAO->query($sSQL);
$row = $objSDAO->fetch();
//output HTML
$aOpz = array("tit2"=>_t("Lista aree funzionali"));
echo(headerHTML($aOpz));
echo(bodyHTML($aOpz));
//output comandi
$aCmd = array("insfa"=>array("pag"=>"functionalAreaIns.php?mod=$module",
										"title"=>_t("Inserisci una nuova area funzionale"),
										"text"=>_t("nuova area funzionale")),
					"da"=>array("pag"=>$objUser->getHistory(-1,false),
										"title"=>$objUser->getHistoryText(-1),
										"text"=>$objUser->getHistoryText(-1),
										"perm"=>"")
					);
echo(commandsHTML($aCmd));	
//output dei dati
$numElem = 0;
echo("<table class='tabl01' width=\"100%\" cellpadding=\"3\" cellspacing=\"2\">\n");
echo("<tr>" .
		"<td class=\"titl01\"colspan=\"4\">".
			_t("Modulo").": '<a class='titl01' href='../modl/moduleView.php?mod=$module&xsn=".XSN.
			"' title='"._t('visualizza modulo')."'>$module</a>' - ".
			$row['mdes']."</td>" .
	 "</tr>\n");
echo("<tr>" .
		"<td class=\"tabh01\" width=\"1%\">&nbsp;</td>" .
		"<td class=\"tabh01\" width=\"20%\">"._t("Area funzionale")."</td>" .
		"<td class=\"tabh01\" width=\"39%\">"._t("Descrizione")."</td>" .
		"<td class=\"tabh01\" width=\"40%\">"._t("note")."</td>" .
	"</tr>\n");
while($row){
	if($row['functional_area']!=''){
		$numElem ++;
		echo("<tr>" .
				"<td class=\"text01\" valign='top'><a class=\"text01\" ".
					goToPag("subModList.php?mod=".$row["module"]."&fa=".$row["functional_area"]."&xsn=".XSN).
					" title=\""._t("Lista sotto-moduli")."'".$row["description"]."'\">".
					"<img src='".SERVER_URL_ROOT."/app/_img/b_engine.png' border='0'>".
					"</a></td>\n" .
				"<td class=\"text01\" valign='top'><a class=\"text01\" ".
				goToPag("functionalAreaView.php?fa=".$row["functional_area"]."&mod=".$row["module"]."&xsn=".XSN).
				" title=\""._t("Modifica area funzionale")."\">".$row["functional_area"]."</a></td>\n" .
				"<td class=\"text01\" valign='top'>".$row["description"]."</td>\n" .
				"<td class=\"text01\" valign='top'><pre class='text01'>".$row["note"]."</pre></td>\n" .
			"</tr>\n");
	}
	$row = $objSDAO->fetch();
}
if($numElem == 0)
	echo("<tr>" .
			"<td class=\"text01\" colspan=\"4\">"._t("Nessuna area funzionale definita")."</td>".
		"</tr>\n");
echo("</table>\n");
echo(commandsHTML($aCmd));
echo(footerHTML());
$objSDAO->close();
?>
